#include "ZenPoint.h"

CZenPoint::CZenPoint()
{
}

CZenPoint::CZenPoint(float x, float y, float z, D3DCOLOR Color)
{
	m_Vertex.m_Position.x = x;
	m_Vertex.m_Position.y = y;
	m_Vertex.m_Position.z = z;

	m_Vertex.m_DiffuseColor = Color;
}

CZenPoint::~CZenPoint()
{
}

HRESULT CZenPoint::Render()
{
	HRESULT					res   = 0;
	LPDIRECT3DVERTEXBUFFER8	pVB   = 0;
	void *					pData = 0;

	res = zen.m_pDevice->CreateVertexBuffer(sizeof(CZenVertex), D3DUSAGE_WRITEONLY, 
											ZENVERTEX_TYPE, D3DPOOL_DEFAULT, &pVB);
	if (FAILED(res))
		return E_FAIL;

	res = pVB->Lock(0, 0, (BYTE**)&pData, 0);
	if (FAILED(res))
	{
		pVB->Release();
		return E_FAIL;
	}

	CopyMemory(pData, (void*)&m_Vertex, sizeof(CZenVertex));

	pVB->Unlock();

	zen.m_pDevice->SetStreamSource(0, pVB, sizeof(CZenVertex));
	zen.m_pDevice->DrawPrimitive(D3DPT_POINTLIST, 0 ,1);
	
	pVB->Release();

	return S_OK;
}

void CZenPoint::SetProps(float x, float y, float z, D3DCOLOR Color)
{
	m_Vertex.m_Position.x = x;
	m_Vertex.m_Position.y = y;
	m_Vertex.m_Position.z = z;

	m_Vertex.m_DiffuseColor = Color;
}

void CZenPoint::GetProps(float &x, float &y, float &z, D3DCOLOR &Color)
{
	x = m_Vertex.m_Position.x;
	y = m_Vertex.m_Position.y;
	z = m_Vertex.m_Position.z;

	Color = m_Vertex.m_DiffuseColor;
}
